<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/2 0002
 * Time: 14:19
 */

namespace app\common\controller;

use think\Controller;

class BaseController extends Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * @param string $msg
     * @param array $data
     * @return \think\response\Json
     */
    protected function successJson($msg = '', $data = [])
    {
        $data = [
            'code' => '000000',
            'msg' => $msg,
            'data' => $data,
        ];
        return json($data);
    }

    /**
     * @param string $msg
     * @param string $code
     * @param array $data
     * @return \think\response\Json
     */
    protected function errorJson($msg = '',$code = '999999', $data = [])
    {
        $data = [
            'code' => $code,
            'msg' => $msg,
            'data' => $data,
        ];
        return json($data);
    }
}